package qtask

import "gitee.com/micro-plat/qtask/internal/modules/const/field"

type opts map[string]interface{}

//Option 配置选项
type Option func(opts)

//WithDeadline 秒数，设置任务截止时间
func WithDeadline(second int) Option {
	return func(o opts) {
		o[field.MaxTimeout] = second
	}
}

// WithDeleteDeadline 秒数，设置任务删除截止时间
func WithDeleteDeadline(second int) Option {
	return func(o opts) {
		o[field.DeleteInterval] = second
	}
}

// WithMaxCount 任务执行最大次数,0一直执行到截止时间
func WithMaxCount(count int) Option {
	return func(o opts) {
		o[field.MaxCount] = count
	}
}

// WithExtNO 拓展单号
func WithExtNO(extNO string) Option {
	return func(o opts) {
		o[field.ExtNo] = extNO
	}
}

// UpdateOption 更新配置选项
type UpdateOption func(opts)

//WithUpdateNextExecuteTime 更新下次执行时间
func WithUpdateNextExecuteTime(second int) UpdateOption {
	return func(o opts) {
		o[field.FirstTimeout] = second
	}
}

//WithUpdateDeadline 秒数，设置任务截止时间
func WithUpdateDeadline(second int) UpdateOption {
	return func(o opts) {
		o[field.MaxTimeout] = second
	}
}

//WithUpdateNextInterval 更新时间间隔
func WithUpdateNextInterval(second int) UpdateOption {
	return func(o opts) {
		o[field.NextInterval] = second
	}
}

// WithUpdateDeleteDeadline 秒数，设置更新任务删除截止时间
func WithUpdateDeleteDeadline(second int) UpdateOption {
	return func(o opts) {
		o[field.DeleteInterval] = second
	}
}

// WithUpdateMaxCount 更新任务执行最大次数
func WithUpdateMaxCount(count int) UpdateOption {
	return func(o opts) {
		o[field.MaxCount] = count
	}
}

// WithUpdateContent 业务内容
func WithUpdateContent(content string) UpdateOption {
	return func(o opts) {
		o[field.MsgContent] = content
	}
}
